package com.cloud.core.utils;

import android.app.Activity;
import android.view.MenuItem;

import com.cloud.core.multistate.NavIconType;
import com.cloud.core.multistate.ToolbarAdapter;
import com.dylanc.loadinghelper.LoadingHelper;
import com.dylanc.loadinghelper.ViewType;

import kotlin.jvm.functions.Function1;

/**
 * Created by Chen on 2020/10/22.
 * Description：
 */
public class ToolbarUtils {
    public static LoadingHelper setToolbar(Activity activity, String title, NavIconType type) {
        return setToolbar(activity, title, type, 0, null);
    }

    public static LoadingHelper setToolbar(Activity activity, String title, NavIconType type, int menuId,
                                           Function1<? super MenuItem, Boolean> onMenuItemClick) {
        LoadingHelper loadingHelper = new LoadingHelper(activity);
        loadingHelper.register(ViewType.TITLE, new ToolbarAdapter(title, type, menuId, onMenuItemClick));
        loadingHelper.setDecorHeader(ViewType.TITLE);
        return loadingHelper;
    }
}
